// common.h -- Defines typedefs and some global functions.
//             From JamesM's kernel development tutorials.

#ifndef COMMON_H
#define COMMON_H
#define FALSE 0
#define TRUE !FALSE
// Some nice typedefs, to standardise sizes across platforms.
// These typedefs are written for 32-bit X86.
typedef unsigned int   u32int;
typedef          int   s32int;
typedef unsigned short u16int;
typedef          short s16int;
typedef unsigned char  u8int;
typedef          char  s8int;

void outb(u16int port, u8int value);
u8int inb(u16int port);
u16int inw(u16int port);
#define MAX_DEV 128
#define IO_READ 0
#define IO_WRITE 1
#define IO_OPEN 2
#define IO_CLOSE 3
struct ior {
	u32int type;
	u32int data1;
	u32int data2;
	u32int data3;
	char datac;
};
typedef struct datetime_s {
	u32int sec;
	u32int min;
	u32int hour;
	u32int day;
	u32int month;
	u32int year;
} datetime_t;
#define PANIC(msg) panic(msg, __FILE__, __LINE__);
#define ASSERT(b) ((b) ? (void)0 : panic_assert(__FILE__, __LINE__, #b))

/* Error codes */
#define ENOSYS 38
extern void panic(const char *message, const char *file, u32int line);
extern void panic_assert(const char *file, u32int line, const char *desc);
extern int kprintf(const char *fmt, ...);
#define sti() asm volatile("sti")
#define cli() asm volatile("cli")
#define hlt() asm volatile("hlt")
#endif // COMMON_H
